home *** CD-ROM | disk | FTP | other *** search
- /*
- ** MacWT -- a 3d game engine for the Macintosh
- ** © 1995, Bill Hayden and Nikol Software
- **
- ** On the Internet:
- ** bmoc1@aol.com (my personal address)
- ** nikolsw@grove.ufl.edu (my school address)
- ** MacWT anonymous FTP site: ftp.circa.ufl.edu/pub/software/ufmug/mirrors/LocalSW/Hayden/
- ** http://grove.ufl.edu:80/~nikolsw (my WWW page, containing MacWT info)
- **
- ** based on wt, by Chris Laurel (claurel@mr.net)
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include "wt.h"
- #include "error.h"
- #include "fixed.h"
- #include "view.h"
- #include "framebuf.h"
- #include "texture.h"
- #include "table.h"
- #include "list.h"
- #include "world.h"
- #include "worldfile.h"
- #include "render.h"
- #include "graphics.h"
- #include "input.h"
- #include "object.h"
- #include "MacWT.h"
-
-
-
-
- void WTMain(char *WorldFile, short width, short height)
- {
- Boolean quit = FALSE;
- Intent *intent;
- extern double gravity;
-
-
- while (!quit)
- {
- double sin_facing, cos_facing;
- double fx, fy, fz;
- fixed shift = 0;
-
- intent = read_input_devices();
-
- while (intent->n_special--)
- {
- switch (intent->special[intent->n_special])
- {
- case INTENT_END_GAME:
- quit = TRUE;
- break;
-
- case INTENT_JUMP:
- case INTENT_ACTION4:
- case INTENT_ACTION5:
- object_apply_force(me, 0.0, 0.0, 50.0);
- break;
-
- case INTENT_ACTION1:
- shift = FIXED_HALF_PI; // Peek left
- break;
-
- case INTENT_ACTION2:
- shift = FIXED_PI; // Peek behind
- break;
-
- case INTENT_ACTION3:
- shift = -FIXED_HALF_PI; // Peek right
- break;
-
- case INTENT_GROW_V:
- case INTENT_SHRINK_V:
- break;
- }
- }
-
- /* Determine forces on viewer. */
- sin_facing = sin(me->angle);
- cos_facing = cos(me->angle);
- fx = cos_facing * intent->force_x - sin_facing * intent->force_y;
- fy = sin_facing * intent->force_x + cos_facing * intent->force_y;
- fz = gravity * me->mass; /* gravity */
-
- /* Apply the forces. */
- object_apply_force(me, fx, fy, fz);
- object_apply_torque(me, intent->force_rotate);
- object_update(me);
-
- object_apply_force(him, fx, fy, 0.0);
- object_update(him);
-
- /* Determine the view. */
- object_view(me, view);
-
- if (shift)
- ShiftViewpoint(view, FIXED_ZERO, FIXED_ZERO, FIXED_ZERO, shift);
-
- /* Display the world. */
- Render(w, view);
- RefreshWTWindow();
- }
-
- EndGraphics();
- }